<?php
include_once ("../Login/databaseconnection.php");
$q=$_GET["q"];
$cs=explode(",",$q);
$Exam_Name=$cs[1];
$Subject=$cs[0];
$hint='';
$resulttable = mysql_query("SELECT DISTINCT(Year) FROM exam WHERE Exam_Name='$Exam_Name' AND Subject='$Subject'");
if($resulttable)
{
$hint=$hint.'<table>';
$hint=$hint.'<tr><td></td><td>Year: </td><td><select name="Year" onChange="get_Okbutton(this.value)"><option value="Select One">Select One</option>';
while($rowtable = mysql_fetch_array($resulttable))
{
$Year=$rowtable['Year'];

$hint=$hint.'<option value="'.$Year.'">'.$Year.'</option>';
}
  $hint=$hint.'</select></td><td></td></tr></table>';
  }
  if($hint=='')
{ 
 $response=$response.'<table>';
 $response=$response.'<tr><td></td><td>Year: </td><td><select name="Year" onChange="get_Okbutton(this.value)"><option value="Select One">Select One</option>';
	 $exa=mysql_query("SELECT DISTINCT(Year) FROM exam");
	  
  while($row=mysql_fetch_array($exa))
  {
   $Yea=$row['Year'];
	$response=$response.'<option value="'.$Yea.'">'.$Yea.'</option>';
  }
$response=$response.'</select></td><td></td></tr></table>';
}
else
{
$response=$hint;
}
echo $response;
 ?>